package org.tigris.subversion.svnant.commands;

import java.io.File;
import org.tigris.subversion.svnant.SvnAntUtilities;
import org.tigris.subversion.svnclientadapter.ISVNClientAdapter;
import org.tigris.subversion.svnclientadapter.SVNClientException;
import org.tigris.subversion.svnclientadapter.SVNUrl;

public class Delete extends ResourceSetSvnCommand
{
  private static final String MSG_CANNOT_DELETE = "Cannot delete file or directory '%s' !";
  private static final String MSG_CANNOT_DELETE_URL = "Cannot delete url '%s'";
  private String message = null;
  private SVNUrl url = null;
  private boolean force = false;

  public Delete()
  {
    super(true, true);
  }

  protected void handleDir(File paramFile, boolean paramBoolean)
  {
    deleteFile(paramFile, this.force);
  }

  protected void handleFile(File paramFile)
  {
    deleteFile(paramFile, this.force);
  }

  protected void handleBegin()
  {
    if (this.url != null)
      deleteUrl(this.url, this.message);
  }

  protected void validateAttributes()
  {
    if (this.url == null)
      super.validateAttributes();
    else
      SvnAntUtilities.attrNotEmpty("message", this.message);
  }

  private void deleteUrl(SVNUrl paramSVNUrl, String paramString)
  {
    try
    {
      getClient().remove(new SVNUrl[] { paramSVNUrl }, paramString);
    }
    catch (SVNClientException localSVNClientException)
    {
      throw ex(localSVNClientException, "Cannot delete url '%s'", new Object[] { paramSVNUrl.toString() });
    }
  }

  private void deleteFile(File paramFile, boolean paramBoolean)
  {
    try
    {
      getClient().remove(new File[] { paramFile }, paramBoolean);
    }
    catch (SVNClientException localSVNClientException)
    {
      throw ex(localSVNClientException, "Cannot delete file or directory '%s' !", new Object[] { paramFile.getAbsolutePath() });
    }
  }

  public void setMessage(String paramString)
  {
    this.message = paramString;
  }

  public void setUrl(SVNUrl paramSVNUrl)
  {
    this.url = paramSVNUrl;
  }

  public void setForce(boolean paramBoolean)
  {
    this.force = paramBoolean;
  }
}

/* Location:           C:\Users\Administrator\Desktop\svnant.jar
 * Qualified Name:     org.tigris.subversion.svnant.commands.Delete
 * JD-Core Version:    0.6.0
 */